<?php
	/**
	* @param $width: the intended width of the canvas
	* @param $height: the intended height of the canvas
	* @param $maxCanvasWidth: the maximal width that the canvas can have in a given workspace
	* @param $maxCanvasHeight: the maximal height that the canvas can have in a given workspace
	*
	* @return an array of 2 elements: factorX and factorY
	*			factorX : if width <= maxWidth, it's 1 else it's the factor which have to be multiplied with the given width, to have the working width
	*			factorY : if height <= maxHeight, it's 1 else it's the factor which have to be multiplied with the given height, to have the working height
	*/
	function calculateWorkspaceCanvasSize($width, $height, $maxCanvasWidth, $maxCanvasHeight){
		$factorX = 1;
		//if($width > $maxCanvasWidth){
			$factorX = round($maxCanvasWidth / $width, 14);
		//}
		
		$factorY = 1;
		//if($height > $maxCanvasHeight){
			$factorY = round($maxCanvasHeight / $height, 14);
		//}
		
		return array($factorX, $factorY);
	}
?>